<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>edoPost</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">


    <!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
    <link rel="stylesheet" href="../node_modules/bootstrap/dist/css/bootstrap.min.css" >

    <link rel="stylesheet" href="../node_modules/summernote/dist/summernote.css">

    <!-- 可选的 Bootstrap 主题文件（一般不用引入） -->
    <!--<link rel="stylesheet" href="./node_modules/bootstrap/dist/css/bootstrap-theme.min.css" >-->

    <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->

    <script src="../node_modules/jquery/dist/jquery.js" ></script>

    <script src="../node_modules/bootstrap/dist/js/bootstrap.js" ></script>

    <script src="../node_modules/summernote/dist/summernote.js"></script>
    <script src="../node_modules/summernote/dist/lang/summernote-zh-CN.js"></script>
    <script src="../node_modules/vue/dist/vue.js"></script>

    <script src="../node_modules/jquery-form/dist/jquery.form.min.js" ></script>
    <script type="text/javascript" src="/jquery.ajax.extend.js"></script>

</head>
<body>



<div class="container-fluid" style="margin: 5px 5px;"  id="edoPostApp">


    <div id="edoPost-grid" v-show="showFlag === 'edoPost-grid'">
        <!--查询form stat-->
        <div class="row" >

            <form class="form-horizontal">


                <div class="form-group col-sm-4">
                    <div class="col-sm-4 control-label">sname</div>
                    <div class="col-sm-8">
                        <input type="text" v-model="edoPostSearchForm.sname" class="form-control input-sm">
                    </div>
                </div>


                <div class="form-group col-sm-4">
                    <div class="col-sm-4 control-label">cateId</div>
                    <div class="col-sm-8">
                        <input type="text" v-model="edoPostSearchForm.cateId" class="form-control input-sm">
                    </div>
                </div>


                <div class="form-group col-sm-4">
                    <div class="col-sm-4 control-label">userName</div>
                    <div class="col-sm-8">
                        <input type="text" v-model="edoPostSearchForm.userName" class="form-control input-sm">
                    </div>
                </div>


                <div class="form-group col-sm-4">
                    <div class="col-sm-4 control-label">tags</div>
                    <div class="col-sm-8">
                        <input type="text" v-model="edoPostSearchForm.tags" class="form-control input-sm">
                    </div>
                </div>


            </form>
        </div>
        <!--查询form ends-->

        <!--查询button start-->
        <div class="row">

            <div class="col-sm-8">
                <div class="btn-group" role="group">

                    <button class="btn btn-default" type="button" @click="edoPostAddModal">
                        新增
                    </button>
                    <button class="btn btn-default" type="button" @click="edoPostImportModal">
                        导入
                    </button>

                    <button class="btn btn-danger" type="button" @click="edoPostDeleteBatchModal()">
                        删除
                    </button>
                    <button class="btn btn-primary" type="button" @click="edoPostExport">
                        导出
                    </button>
                </div>
            </div>
            <div class="col-sm-4  text-right">
                <div class="btn-group" role="group">

                    <button class="btn btn-success" type="button" @click="doSearch">
                        查询
                    </button>
                    <button class="btn btn-default" type="button" @click="doClear">
                        清空
                    </button>

                </div>
            </div>
        </div>
        <!--查询button ends-->

        <div class="row">


            <!--分页 start-->
            <ul class="pagination  pagination-sm" style="margin-top: 5px; margin-bottom: 5px;">
                <!--<li class="page-item">-->
                <!--<a class="page-link" href="#"><i @click="switchToPage(1)">&laquo;</i></a>-->
                <!--</li>-->
                <li class="page-item">
                    <a href="#"  class="page-link" @click="goBack"><i>&lt;</i></a>
                </li>
                <li class="page-item" v-for="n in pageNumList" :class="{active:n == pageNow}">
                    <a href="#"  @click="switchToPage(n)" class="page-link">{{n}}</a>
                </li>
                <li class="page-item">
                    <a href="#"   class="page-link"  @click="goNext"><i>&gt;</i></a>
                </li>
                <li class="page-item">
                    <span class="badge">共 {{totalRows}} 条</span>
                </li>
                <!--<li class="page-item">-->
                <!--<a href="#"   class="page-link"><i  @click="switchToPage(totalPages)">&raquo;</i></a>-->
                <!--</li>-->
            </ul>
            <!--分页 ends-->


            <!--表格数据 start-->
            <table class="table table-hover table-striped table-bordered table-sm table-condensed" style="margin-top: 5px;">
                <thead >
                <tr>
                    <th>
                        <button type="button" class="btn btn-sm" @click="fnChangeAll">全部</button>

                    </th>
                    <th>#</th>

                    <th>标题</th>
                    <th>创建时间</th>
                    <th>分类</th>
                    <th>tag分类</th>
                    <th>用户名</th>
                    <th>回复数</th>

                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <tr v-for="(item,index) in edoPostList" @click="fnChangeStatus(index)">
                    <td><input class="form-control" disabled type="checkbox" :value="index" v-model="checkedRows"></td>
                    <td>{{(pageNow-1)*10 + index+1}}</td>

                    <td>{{item.sname}}</td>
                    <td>{{item.ctime}}</td>
                    <td>{{item.cateName}}</td>
                    <td>{{item.tags}}</td>
                    <td>{{item.userName}}</td>
                    <td>
                        <a class="btn btn-primary btn-xs" href="#" @click="edoReplyModal(item)" >{{item.replyNum}}</a>
                    </td>
                    <td>

                        <button type="button" class="btn btn-sm  btn-primary" @click="edoPostUpdateModal(item)">编辑</button>
                        <button type="button"  class="btn btn-sm btn-danger"  @click="edoPostDeleteOneModal(item)">删除</button>
                    </td>
                </tr>
                </tbody>
            </table>
            <!--表格数据 ends-->



        </div>

    </div>

    <!--add modal start-->

    <div id="edoPost-detail" v-show="showFlag === 'edoPost-add' || showFlag === 'edoPost-update' || showFlag === 'edoPost-detail'">


        <div class="modal-footer">
            <button type="button" class="btn btn-default" @click="edoPostGridModal">返回</button>
            <button type="button" class="btn btn-primary" @click="edoPostAddOrUpdate">提交</button>
        </div>



        <div class="panel-group" id="accordion">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h4 class="panel-title">
                        <a data-toggle="collapse" data-parent="#accordion"
                           href="#edoPostcollapse1">
                            基本信息
                        </a>
                    </h4>
                </div>
                <div id="edoPostcollapse1" class="panel-collapse collapse in">
                    <div class="panel-body">

                        <form class="form-horizontal"  role="form">

                            <div class="form-group col-sm-6" v-show="false">
                                <label for="" class="col-sm-4 control-label">sid</label>
                                <div class="col-sm-8">

                                    <input type="text" class="form-control" readonly v-model="edoPostDataForm.sid">

                                </div>
                            </div>

                            <div class="form-group col-sm-6">
                                <label for="" class="col-sm-4 control-label">标题</label>
                                <div class="col-sm-8">

                                    <input type="text" class="form-control" v-model="edoPostDataForm.sname">

                                </div>
                            </div>

                            <div class="form-group col-sm-6">
                                <label for="" class="col-sm-4 control-label">分类</label>
                                <div class="col-sm-8">

                                    <select  class="form-control" v-model="edoPostDataForm.cateId">

                                        <option v-for="option in edoCateList" v-bind:value="option.sid">
                                            {{ option.sname }}
                                        </option>

                                    </select>

                                </div>
                            </div>

                            <div class="form-group col-sm-6">
                                <label for="" class="col-sm-4 control-label">tags</label>
                                <div class="col-sm-8">

                                    <input type="text" class="form-control" v-model="edoPostDataForm.tags">
                                    <div class="checkbox">


                                        <template v-for="tag in sysTagList">

                                            <label class="checkbox-inline">
                                                <input type="checkbox" @change="doChange"  v-model="edoPostDataForm.tagsList" :value="tag.tagName">{{tag.tagName}}
                                            </label>
                                        </template>

                                    </div>
                                </div>
                            </div>

                            <div class="form-group col-sm-12">
                                <label for="" class="col-sm-2 control-label">内容</label>
                                <div class="col-sm-10">
                                    <textarea class="summernote form-control" id="summernote"  v-model="edoPostDataForm.txt"></textarea>
                                </div>
                            </div>


                            <div class="form-group col-sm-6">
                                <label for="" class="col-sm-4 control-label">用户名</label>
                                <div class="col-sm-8">

                                    <input type="text" class="form-control" v-model="edoPostDataForm.userName">

                                </div>
                            </div>

                            <div class="form-group col-sm-6">
                                <label for="" class="col-sm-4 control-label">手机号</label>
                                <div class="col-sm-8">

                                    <input type="text" class="form-control" v-model="edoPostDataForm.userPhone">

                                </div>
                            </div>



                        </form>
                    </div>
                </div>
            </div>
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h4 class="panel-title">
                        <a data-toggle="collapse" data-parent="#accordion"
                           href="#edoPostcollapse2">
                            其他
                        </a>
                    </h4>
                </div>
                <div id="edoPostcollapse2" class="panel-collapse collapse">
                    <div class="panel-body">

                        do sth
                    </div>
                </div>
            </div>
        </div>


    </div>

    <!--add modal ends-->


<!--reply start-->


    <div id="edoPost-reply" v-show="showFlag === 'edoPost-reply' ">

        <div class="modal-footer">
            <button type="button" class="btn btn-default" @click="edoPostGridModal">返回</button>
            <button type="button" class="btn btn-default" @click="edoShowAddReplyModal">添加回复</button>
        </div>

        <div class="panel panel-default">
            <div class="panel-heading">
                <h3 class="panel-title">
                      {{edoPostDataForm.ctime}} -- {{edoPostDataForm.sname}}
                </h3>
            </div>
            <div class="panel-body">

                <p>{{edoPostDataForm.txt}}</p>
            </div>
        </div>



            <template v-for="item in edoReplyList">
                <div class="panel panel-info">
                    <div class="panel-heading">
                        <h3 class="panel-title">{{item.ctime}}  <span class="badge">{{item.userName}}</span></h3>
                    </div>
                    <div class="panel-body">
                       <p> {{item.txt}}</p>
                    </div>
                </div>

            </template>

    </div>

    <!--reply ends-->


    <!--tip start-->

    <!-- 模态框（Modal） -->
    <div class="modal fade" id="modal-container-edoPost" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                    <h4 class="modal-title" id="myModalLabel">提示</h4>
                </div>
                <div class="modal-body"><p>{{tipMsg}}</p></div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary" v-show="confirmFlag" @click="edoPostDelete">确定</button>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div>
    <!-- /.modal -->


    <!-- 回复 模态框（Modal） -->
    <div class="modal fade" id="modal-container-edoReply" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                    <h4 class="modal-title" id="">回复</h4>
                </div>
                <div class="modal-body">

                    <form class="form-horizontal"  role="form">

                        <div class="form-group col-sm-12" v-show="false">
                            <label for="" class="col-sm-3 control-label">sid</label>
                            <div class="col-sm-9">

                                <input type="text" class="form-control" readonly v-model="edoReplyDataForm.sid">

                            </div>
                        </div>

                        <div class="form-group col-sm-12" v-show="false">
                            <label for="" class="col-sm-3 control-label">所属postId</label>
                            <div class="col-sm-9">

                                <input type="text" readonly class="form-control" v-model="edoReplyDataForm.postId">

                            </div>
                        </div>


                        <div class="form-group col-sm-12">
                            <label for="" class="col-sm-3 control-label">内容</label>
                            <div class="col-sm-9">

                                <textarea class="form-control" rows="10" v-model="edoReplyDataForm.txt"></textarea>
                            </div>
                        </div>

                        <div class="form-group col-sm-12">
                            <label for="" class="col-sm-3 control-label">用户名</label>
                            <div class="col-sm-9">

                                <input type="text" class="form-control" v-model="edoReplyDataForm.userName">

                            </div>
                        </div>

                        <div class="form-group col-sm-12">
                            <label for="" class="col-sm-3 control-label">手机号</label>
                            <div class="col-sm-9">

                                <input type="text" class="form-control" v-model="edoReplyDataForm.userPhone">

                            </div>
                        </div>



                    </form>

                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary"  @click="edoReplyAdd">提交</button>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div>
    <!-- /.modal -->

    <!--tip ends-->



    <!-- 导入 模态框（Modal） -->
    <div class="modal fade" id="modal-container-edoPostImport" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                    <h4 class="modal-title" id="myModalLabel">导入</h4>
                </div>
                <div class="modal-body">

                    <form id="edoPostImportForm" method="post"  enctype="multipart/form-data">
                        <div class="form-group">
                            <label for="">选择文件</label>
                            <input type="file" name="file" id="edoPostFile">
                            <p class="help-block">请选择要上传的文件。</p>
                        </div>

                        <br/>
                    </form>

                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary"  @click="edoPostImport">确定</button>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div>
    <!-- /.modal -->




</div>
</body>
</html>


<script>

    var vm = new Vue({
        el: '#edoPostApp',
        data: {
            edoPostSearchForm:{},
            edoPostDataForm:{tagsList:[]},
            edoPostList:[],
            perPage:10,
            pageNow:1,
            totalPages:5,
            checkedRows:[],
            pageNumList:[],
            totalRows:0,
            checked:false,
            updateFlag:false,
            showFlag:'edoPost-grid',
            tipMsg: '',
            confirmFlag:false,
            deleteIds:[],

            edoCateList:[],

            edoReplyDataForm:{},
            edoReplyList:[],
            sysTagList:[],



        },
        methods: {


            serializ:function () {

                var arr = [];
                var edoPostSearchForm = this.edoPostSearchForm;
                for(var k in edoPostSearchForm){
                    arr.push([k,'=',edoPostSearchForm[k]].join(''));
                }
                return arr.join("&");
            },


            edoShowAddReplyModal:function () {

                $('#modal-container-edoReply').modal('show');
            },
            edoPostImportModal:function () {

                $('#modal-container-edoPostImport').modal('show');
            },


            edoPostImport:function () {

                var _self = this;

                var file = $("#edoPostFile").val();
                if (file == "") {
//                    alert("请选择要上传的文件");
                    $('#modal-container-edoPostImport').modal('hide');
                    _self.popTipModal('请选择要上传的文件！');
                    return false
                }

                $("#edoPostImportForm").ajaxSubmit({

                    type:"post",
                    url:'/edoPost/import',
                    success:function (data) {
//                        console.log(data);
                        if(data.code == '0'){

                            $('#modal-container-edoPostImport').modal('hide');
                            _self.popTipModal('上传成功！');
                            _self.doSearch();

                        }else{
                            $('#modal-container-edoPostImport').modal('hide');
                            _self.popTipModal(data.msg);
                        }
                    }
                });
                return false;
            },

            edoPostExport:function () {

                window.open('/edoPost/export?'+this.serializ())
            },


            //提示框 弹框
            popTipModal:function (msg,confirmFlag) {

                this.tipMsg = msg;
                if(!!confirmFlag){
                    this.confirmFlag = true;
                }else{
                    this.confirmFlag = false;
                }

                $('#modal-container-edoPost').modal('show');
            },


            //返回 主页面
            edoPostGridModal:function () {

                this.showFlag = 'edoPost-grid';
            },

            //新增弹框
            edoPostAddModal:function () {

                this.edoPostDataForm = { tagsList:[]};
                this.showFlag = 'edoPost-add';
                this.updateFlag = false;

            },

            //修改弹框
            edoPostUpdateModal:function (item) {

                var _self = this;
                var _sid = item.sid?item.sid:item.id;
                $.ajax({
                    url:'/edoPost/get/' + _sid,
                    data: _self.edoPostSearchForm,

                }).done(
                    function (dat) {
                        if (dat.code == 0) {
                            var data = dat.data;
                            _self.edoPostDataForm = data;
                            $('#summernote').summernote('code', _self.edoPostDataForm.txt);
                            _self.showFlag = 'edoPost-update';
                            _self.updateFlag = true;
                        }
                    }
                );
            },

            //回复
            edoReplyModal:function (item) {



                var _self = this;
                var _sid = item.sid?item.sid:item.id;

                window.open('/view/edoPostReply.html?postId='+_sid);

                return;

                $.ajax({
                    url:'/edoPost/get/' + _sid,

                }).done(
                    function (dat) {
                        if (dat.code == 0) {
                            var data = dat.data;
                            _self.edoPostDataForm = data;
                        }
                    }
                );

                _self.edoReplyDataForm = { postId: _sid};
                $.ajax({
                    url:'/edoPostReply/all?postId=' + _sid,
//                    data: _self.edoPostSearchForm,

                }).done(
                    function (dat) {
                        if (dat.code == 0) {
                            var data = dat.data;
                            _self.edoReplyList = data;
                            _self.showFlag = 'edoPost-reply';
                        }
                    }
                );
            },

            //删除一个 弹框
            edoPostDeleteOneModal:function (item) {

                var _sid = item.sid?item.sid:item.id;
                this.deleteIds = [_sid];
                this.popTipModal('确定要删除选中的数据吗？',true);
            },

            //删除多个 弹框
            edoPostDeleteBatchModal:function () {

                var len = this.checkedRows.length;
                if(len<=0){
                    this.popTipModal('请选择要删除的数据');
                    return false;
                }

                this.deleteIds = [];
                for(var i=0;i<len;i++){
                    var indx = this.checkedRows[i];
                    var item = this.edoPostList[indx];
                    var _sid = item.sid?item.sid:item.id;
                    this.deleteIds.push(_sid);
                }
                this.popTipModal('确定要删除选中的数据吗？',true);
            },


            //删除 提交
            edoPostDelete:function () {

                var _self = this;

                $.ajax({
                    url:'/edoPost/delete?ids='+_self.deleteIds,
                    type: "POST",
                    datType: "JSON",
                }).done(
                    function (dat) {
                        if (dat.code == 0) {
                            _self.popTipModal('操作成功！');
                            _self.switchToPage(1);

                        }else{
                            _self.popTipModal(dat.msg);
                        }
                    }
                );

            },

            fnChangeAll: function () {

                var length = this.checkedRows.length;
                if(length>0){
                    this.checkedRows = [];
                }else{
                    var size=this.edoPostList.length;
                    for(var i=0;i<size;i++){
                        this.checkedRows.push(i);
                    }
                }

            },

            fnChangeStatus:function (indx) {

                var number = this.checkedRows.indexOf(indx);
                if(number> -1){
                    this.checkedRows.splice(number, 1);
                }else{
                    this.checkedRows.push(indx);
                }
            },
            doSearch:function () {
                this.switchToPage(1);
            },
            doClear:function () {
                this.edoPostSearchForm={};
                this.switchToPage(1);
            },

            edoReplyAdd:function () {

                var _self = this;
                var postUrl = "/edoPostReply/add";
                var _sid = this.edoPostDataForm.sid?this.edoPostDataForm.sid:this.edoPostDataForm.id;

                //
                $.ajax({
                    url:postUrl,
                    data: JSON.stringify(_self.edoReplyDataForm),
                    type: "POST",
                    datType: "JSON",
                    contentType: "application/json"

                }).done(
                    function (dat) {
                        if (dat.code == 0) {
                            _self.popTipModal('操作成功！');

                            $('#modal-container-edoReply').modal('hide');
                            if(dat.data.sid){
                                _self.edoReplyDataForm.sid=dat.data.sid;
                            }
                            if(dat.data.id){
                                _self.edoReplyDataForm.id=dat.data.id;
                            }
                            _self.switchToPage(1);

                            _self.edoReplyModal({sid:_sid});

                        }else{
                            _self.popTipModal(dat.msg);
                            $('#modal-container-edoReply').modal('hide');
                        }
                    }
                );
            },

            // 新增,修改 提交
            edoPostAddOrUpdate:function () {

                var _self = this;
                var postUrl = "/edoPost/add";
                var _sid = this.edoPostDataForm.sid?this.edoPostDataForm.sid:this.edoPostDataForm.id;
                if(_sid ){
                    postUrl = "/edoPost/update";
                }

                var _txt = $('#summernote').summernote('code');
                _self.edoPostDataForm.txt = _txt;
                //
                $.ajax({
                    url:postUrl,
                    data: JSON.stringify(_self.edoPostDataForm),
                    type: "POST",
                    datType: "JSON",
                    contentType: "application/json"

                }).done(
                    function (dat) {
                        if (dat.code == 0) {
                            _self.popTipModal('操作成功！');

                            if(dat.data.sid){
                                _self.edoPostDataForm.sid=dat.data.sid;
                            }
                            if(dat.data.id){
                                _self.edoPostDataForm.id=dat.data.id;
                            }
                            _self.switchToPage(1);

                        }else{
                            _self.popTipModal(dat.msg);
                        }
                    }
                );

            },

            switchToPage:function (pageNum) {

                this.checkedRows=[];
                if( pageNum >= this.totalPages){
                    pageNum = this.totalPages;
                }
                if(pageNum <= 0 ){
                    pageNum = 1;
                }

                this.pageNow = pageNum;
                this.getDataList(pageNum);

            },


            goBack:function () {
                var nowMinPage = this.pageNumList[0];
                if(!nowMinPage ||nowMinPage <= 1){
                    return ;
                }
                var start = nowMinPage-1-10;

                this.pageNumList = [];
                for(var i= start+1;i <= nowMinPage-1;i++){

                    this.pageNumList.push(i);
                }

                var page = this.pageNumList[this.pageNumList.length -1];
                this.pageNow = page;

                var _self = this;
                this.ajaxQuery(page,_self);

            },
            goNext:function () {
                var nowMaxPage = this.pageNumList[this.pageNumList.length -1];
                if(!nowMaxPage || nowMaxPage >= this.totalPages){
                    return ;
                }
                var end = nowMaxPage+10;
                if(end > this.totalPages){
                    end = this.totalPages;
                }

                this.pageNumList = [];
                for(var i= nowMaxPage+1;i <= end;i++){
                    this.pageNumList.push(i);
                }

                var page = nowMaxPage+1;
                this.pageNow = page;

                var _self = this;
                this.ajaxQuery(page,_self);

            },

            //查询
            getDataList: function (page) {

                var _self = this;
                this.ajaxQuery(page,_self);

            },
            ajaxQuery:function (page, _self) {

                _self.checkedRows=[];
                $.ajax({
                    url:'/edoPost/pageInfo?current='+page +'&size='+10,
                    data: _self.edoPostSearchForm,

                }).done(
                    function (dat) {
                        if (dat.code == 0) {
                            var data = dat.data;
                            var dataList=data.records;
                            _self.edoPostList=[];
                            for(var i in dataList){
                                _self.edoPostList.push(dataList[i]);
                            }
                            _self.totalRows = data.total;
                            _self.totalPages= Math.ceil(data.total/data.size);

                            //前10页,
                            if(page <= 10){

                                _self.pageNumList = [];
                                var maxNavNum = _self.totalPages>10?10:_self.totalPages;
                                for(var i=0;i<maxNavNum;i++){
                                    _self.pageNumList.push(i+1);
                                }
                            }

                        }
                    }
                );
            },


            getCateList:function () {

                var _self = this;
                $.ajax({
                    url:'/edoCate/all',
                    type: "POST",
                    datType: "JSON",

                }).done(
                    function (dat) {
                        if (dat.code == 0) {

                            _self.edoCateList = dat.data;

                        }else{
                            _self.popTipModal(dat.msg);
                        }
                    }
                );
            },
            getTagList:function () {

                var _self = this;
                $.ajax({
                    url:'/edoTag/all' ,

                }).done(
                    function (dat) {
                        if (dat.code == 0) {
                            _self.sysTagList = dat.data;

                        }
                    }
                );
            },

            doChange:function () {

                this.edoPostDataForm.tags = this.edoPostDataForm.tagsList.join(",");
            }

        },
        mounted: function () {

            this.switchToPage(1);

            this.getCateList();
            this.getTagList();


            $('#summernote').summernote({
                lang: 'zh-CN',
                height: 300,

//                toolbar:[
//                    ['style',['bold','italic','underline','clear']],
//                    ['fontsize',['fontsize']],
//                    ['para',['ul','ol','paragraph']],
//                    ['color',['color']]
//                ],

                callbacks: {
                    onImageUpload: function(file) {  //图片默认以二进制的形式存储到数据库，调用此方法将请求后台将图片存储到服务器，返回图片请求地址到前端

                        //将图片放入Formdate对象中
                        var formData = new FormData();
                        //‘picture’为后台获取的文件名，file[0]是要上传的文件
                        formData.append("file", file[0]);
                        $.ajax({
                            type:'post',
                            url:'/file/upload1',
                            cache: false,
                            data:formData,
                            processData: false,
                            contentType: false,
//                            dataType:'text', //请求成功后，后台返回图片访问地址字符串，故此以text格式获取，而不是json格式
                            success: function(dat) {
                                $('#summernote').summernote('insertImage',dat.msg);
                            },
                            error:function(){
                                alert("上传失败");
                            }
                        });
                    }
                }

            });

        },
        watch:{



        }
    });

</script>